﻿// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

// ReSharper disable CheckNamespace

#region Using directives

using System;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using AM.Text;

#endregion

#nullable enable

namespace UnitTests.AM.Text;

[TestClass]
public sealed class NewLineTest
{
    private void _Test
        (
            string? expected,
            Func<string?, string?> func,
            string? argument
        )
    {
        var actual = func (argument);

        Assert.AreEqual (expected, actual);
    }

    [TestMethod]
    [Description ("Удаление переводов строки")]
    public void NewLine_RemoveLineBreaks_1()
    {
        _Test (null, NewLine.RemoveLineBreaks, null);
        _Test ("", NewLine.RemoveLineBreaks, "");
        _Test ("", NewLine.RemoveLineBreaks, "\n");
        _Test (" ", NewLine.RemoveLineBreaks, " ");
    }

    [TestMethod]
    [Description ("Преобразование переводов строки Unix в DOS")]
    public void NewLine_UnixToDos_1()
    {
        _Test (null, NewLine.UnixToDos, null);
        _Test ("", NewLine.UnixToDos, "");
        _Test ("\r\n", NewLine.UnixToDos, "\n");
        _Test (" ", NewLine.UnixToDos, " ");
    }

    [TestMethod]
    [Description ("Преобразование переводо строки DOS в Unixs")]
    public void NewLine_DosToUnix_1()
    {
        _Test (null, NewLine.DosToUnix, null);
        _Test ("", NewLine.DosToUnix, "");
        _Test ("\n", NewLine.DosToUnix, "\r\n");
        _Test (" ", NewLine.DosToUnix, " ");
    }
}
